<?php
/*
 * =====================================================================================
 *
 *       Filename: config.php  
 *
 *    Description:所有全局参数实现的地方，定义常量、数据库相关的设置；引用settings.php 获取全局变量
 *
 *        Version:  1.0
 *        Created:  05/15/2011 12:29:39 PM
 *
 *         Author:  rainphp@gmail.com
 *        Company:  Anonymous
 *
 * =====================================================================================
 */
	/**
	 * Starts the timer, for debugging purposes.
	 *
	 * @since 1.5.0
	 *
	 * @return true
	 *
	function timer_start() {
		$mtime            = explode( ' ', microtime() );
		$time_start = $mtime[1] + $mtime[0];
		return true;
	}*/

	/**
	 * Stops the debugging timer.
	 *
	 * @since 1.5.0
	 *
	 * @return int Total time spent on the query, in milliseconds
	 *
	function timer_stop() {
		$mtime      = explode( ' ', microtime() );
		$time_end   = $mtime[1] + $mtime[0];
		$time_total = $time_end - $time_start;
		return $time_total;
	}*/

//根据网址，获得网页的内容

function get_page_content($url,$timeout=3,$useragent = 'Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1; Trident/4.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0; InfoPath.2)')
{
	//$useragent = 'Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1; Trident/4.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0; InfoPath.2)';

	$ch = curl_init(); 

	//$timeout = 3; 
	//echo  $_SERVER['HTTP_USER_AGENT'];

	curl_setopt($ch, CURLOPT_USERAGENT,  $useragent);

	curl_setopt($ch, CURLOPT_URL, $url); 

	curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); 

	curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, $timeout); 

	//在需要用户检测的网页里需要增加下面两行 

	//curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_ANY); 

	//curl_setopt($ch, CURLOPT_USERPWD, US_NAME.":".US_PWD); 

	$contents = curl_exec($ch); 

	curl_close($ch); 

	return  $contents; 

}
?>
